﻿@model PagedList.IPagedList<TaoNiuOA.Models.Checking>
@using PagedList;
@{
    ViewBag.Title = "我的考勤";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<fieldset>
    <legend>我的考勤</legend>
    <div>
        <ul>
            <li><a href="?mod=today">今天</a></li>
            <li><a href="?mod=yesterday">昨天</a></li>
            <li><a href="?mod=thismonth">本月</a></li>
            <li><a href="?mod=lastmonth">上月</a></li>
            <li><a href="?mod=all">所有考勤</a></li>
        </ul>
    </div>
    <div>
        <form id="form1">
        <script src="../../Plusins/timeplus/WdatePicker.js" type="text/javascript"></script>
        <input type="text" id="searchTime" name="searchTime" />
        <input type="button" id="btnSearch" name="btnSearch" value="查询" />(形式如2011-11-11或2011-11,如月或日不足10位用0补足,如2011-01-01)
        </form>
    </div>
    <table>
        <tr>
            <th>
                用户名
            </th>
            <th>
                姓名
            </th>
            <th>
                日期
            </th>
            <th>
                上班时间
            </th>
            <th>
                下班时间
            </th>
            <th>
                是否请假
            </th>
            <th>
                备注
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.GetUser().UserName
                </td>
                <td>
                    <a href="/user/details/@item.UserID">@item.GetUser().GetUserInfo().Name</a>
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Date)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.OnWork)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.OffWork)
                </td>
                <td>
                    @if (item.IsLeave == true)
                    {
                        @Html.Raw("是")
                    }
                    else
                    {
                        @Html.Raw("否")
                    }
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Remark)
                </td>
            </tr>
        }
    </table>
    <div style="width: auto; height: 30px; margin-top: 20px; text-align: center;">
        @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
        / @Model.PageCount
        &nbsp;
        @if (Model.HasPreviousPage)
        {
            @Html.ActionLink("首页", ViewData["actionName"].ToString(), new { mod = ViewData["mod"], page = 1, currentFilter = ViewBag.CurrentFilter })
            @Html.Raw("&nbsp;");
            @Html.ActionLink(" 上一页", ViewData["actionName"].ToString(), new { mod = ViewData["mod"], page = Model.PageNumber - 1, currentFilter = ViewBag.CurrentFilter })
        }
        else
        {
            @Html.Raw("首页&nbsp;&nbsp;上一页")
        }
        &nbsp;
        @if (Model.HasNextPage)
        {
            @Html.ActionLink("下一页 ", ViewData["actionName"].ToString(), new { mod = ViewData["mod"], page = Model.PageNumber + 1, currentFilter = ViewBag.CurrentFilter })
            @Html.Raw("&nbsp;");
            @Html.ActionLink("尾页", ViewData["actionName"].ToString(), new { mod = ViewData["mod"], page = Model.PageCount, currentFilter = ViewBag.CurrentFilter })
        }
        else
        {
            @Html.Raw("下一页&nbsp;&nbsp;尾页")
        }
    </div>
</fieldset>
<script type="text/javascript">
    var btn = document.getElementById("btnSearch");
    var frm = document.getElementById("form1");
    var search = document.getElementById("searchTime");
    btn.onclick = function () {
        if (che()) {
            frm.method = "post";
            frm.action = "?mod=" + search.value;
            frm.submit();
        }
    }
    function che() {
        if (search.value == "") {
            alert("请选择时间");
            return false;
        }
        else {
            if (search.value.indexOf("-") == -1) {
                alert("请输入正确的时间,如:2011-11");
                return false;
            }
        }
        return true;
    }
</script>
